﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using HaoHaoCloud.Models;
using HHXX.IBLL;
using HHXX.IDAL;

namespace HaoHaoCloud.Controllers
{
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> _logger;
        //public IUserInfoService _iUserInfoService { get; set; }
        //public IUserInfoDal userInfoDal { get; set; }
        private readonly IUserInfoService _iUserInfoService = null;
        public HomeController(ILogger<HomeController> logger, IUserInfoService userInfoService)
        {
            _logger = logger;
            _iUserInfoService = userInfoService;
        }

        public IActionResult Index()
        {
            this._logger.LogWarning("This is HomeController-Index");
            return View();
        }

        public IActionResult Privacy()
        {
            return View();
        }

        [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
        [HttpGet]
        public ContentResult Test()
        {
            string res = "111";

            try
            {
                _iUserInfoService.Add(new HHCloud.Model.Models.UserInfoSet
                {
                    Uname = "nnn",
                    Pwd = "123456",
                    ShowName = "nnn",
                    DelFlag = 0,
                    ModifiedOn = DateTime.Now,
                    SubTime = DateTime.Now
                });
                res = "success!";
            }
            catch(Exception ex)
            {
                res = ex.Message;
            }

            return Content(res, "application/json");
        }

    }
}
